package com.njupt.swg.threadstudyjimin.item05.publish;

import com.njupt.swg.threadstudyjimin.annotation.NotRecommend;
import com.njupt.swg.threadstudyjimin.annotation.NotThreadSafe;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@NotThreadSafe
@NotRecommend
public class Escape {
    private int thisCanBeEscape = 1;

    public Escape(){
        new InnerClass();
    }

    //new Escape();还没构造完成，其他线程已经看到这个对象，不安全
    private class InnerClass{
        public InnerClass(){
            log.info("{}",Escape.this.thisCanBeEscape);//1
        }
    }

    public static void main(String[] args) {
        new Escape();
    }
}
